<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>活动-基本设置</title>
    <link rel="stylesheet" href="layui/css/layui.css">
    <link rel="stylesheet" href="./css/business.css">
</head>
<body>
<div id="uniocn" class="layui-layout layui-layout-admin">
    <div class="financeTitle">
        <button class="layui-btn layui-btn-ms">基本设置</button>
    </div>
    <div class="activityBox">
        <p class="activityTitle">基本设置</p>
        <form action="##" class="layui-form" style="box-sizing: border-box;margin: 15px">
            <div class="layui-form-item">
                <label class="layui-form-label">商品编码</label>
                <div class="layui-input-inline" style="width: 45%;">
                    <input type="text" name="number" required  lay-verify="required" placeholder="请输入商品编码" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">商品名称</label>
                <div class="layui-input-inline" style="width: 45%;">
                    <input type="text" name="name" required  lay-verify="required" placeholder="请输入商品名称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">海报图片</label>
                <div class="layui-input-inline" style="margin-right: 0 ;width: 45%;">
                    <input class="layui-input">
                    <p class="tip">图片建议700*700</p>
                    <div class="layui-upload-list">
                        <img class="layui-upload-img shopImg" id="demo1">
                        <p id="demoText"></p>
                    </div>
                </div>
                <button id="test1" class="layui-btn layui-btn-primary">选择图片</button>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">商品图集</label>
                <div class="layui-input-inline" style="margin-right: 0 ;width: 45%;">
                    <input class="layui-input" disabled>
                    <p class="tip">图片建议700*700</p>
                    <div class="layui-upload">
                            <div class="layui-upload-list basicImg" id="demo2"></div>
                    </div>
                </div>
                <button id="test2" class="layui-btn layui-btn-primary">选择图片</button>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">商品单位</label>
                <div class="layui-input-inline" style="width: 45%;">
                    <input type="text" name="Company" required  lay-verify="required" placeholder="请输入商品单位" autocomplete="off" class="layui-input">
                </div>
            </div><div class="layui-form-item">
                <label class="layui-form-label">商品标签</label>
                <div class="layui-input-inline" style="width: 45%;">
                    <input type="text" name="label" required  lay-verify="required" placeholder="请输入商品标签" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">购买须知</label>
                <div class="layui-input-inline" style="width:60%;">
                    <textarea id="demo" style="display: none;"></textarea>
                </div>
            </div><div class="layui-form-item">
                <label class="layui-form-label">商品详情</label>
                <div class="layui-input-inline" style="width:60%;">
                    <textarea id="edit" style="display: none;"></textarea>
                </div>
            </div>
            <div class="layui-form-item" style="margin-top: 20px">
                <div class="layui-input-block" style="width:45%;">
                   <button class="layui-btn">提交</button>
                </div>
            </div>
        </form>
    </div>
</div>
</body>
<script src="layui/layui.js"></script>
<script src="js/jquery-3.2.1.min.js"></script>
<script>
    layui.use(['form', 'upload','layedit'], function () {
        var form = layui.form;
        var upload = layui.upload;
        var layedit = layui.layedit;
        //执行实例
        //普通图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            , url: '/upload/'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });


        upload.render({
            elem: '#test2'
            ,url: '/upload/'
            ,multiple: true
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">')
                });
            }
            ,done: function(res){
                //上传完毕
            }
        });


        layedit.build('demo'); //建立编辑器
        layedit.build('edit'); //建立编辑器
    })
</script>
</html>